﻿@model SnippetBox.Web.Models.SearchModel
@{
    ViewBag.Title = "Search results for " + Model.SearchQuery;
}

<h1>Your search results</h1>

@if (Model.IsEmptyResults) {
    <p>Sorry, your search query didn't return any results. Please try another search term.</p>
}
else {
    <p class="gray">Your search term "<mark>@Model.SearchQuery</mark>" returned @Model.SearchResultsCount result@(Model.SearchResultsCount != 1 ? "s" : "").</p>
    <hr />
}

@if (Model.Categories != null && Model.Categories.PageCount > 0) {
    <div class="categoryTags">
        <h2>Categories</h2>
    
        @foreach (var category in Model.Categories) {
             <a href="@category.Link">@category.Name</a>
        }
    </div>
    <hr />
}

@if (Model.Snippets != null && Model.Snippets.PageCount > 0) {
    <h2>Snippets</h2>
    
    @Html.DisplayFor(m => m.Snippets)
    
    if (Model.Snippets.PageCount > 1) {
        @Html.Pager(Model.Snippets)
    }
}